<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>体育与健康课程管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/main.css"/>
    <link href="${pageContext.request.contextPath}/public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/public/js/layer/layer.js"></script>
    <script src="${pageContext.request.contextPath}/public/bootstrap/js/bootstrap.min.js"></script>
</head>
<style>
    .addtab
    {
        float:left;
        /*    margin-top:10px;*/
        margin-left: 90px;
    }
    .addtab tr
    {
        float:left;
        margin-top: 20px;
        width:300px;
    }
    .addtab th
    {
        width:90px;
        font-size: 15px;
        font-family: '微软雅黑';
        color:#000;
        float:left;
        font-weight:normal;
    }
    .addtab input
    {
        border-radius: 5px;
        float:left;
        height:30px;
    }
    .btn12
    {
        width:160px;
        height:40px;
        letter-spacing: 10px;
        font-size: 16px;

    }
    .require-red {
        color: #f60;
        font-family: serif;
        margin-right: 3px;
    }

</style>
<body>
<p style="margin-top:15px;margin-left:40px; font-size:16px; border-left:3px #006dcc solid; padding-left:5px">查看模块消息</p>
<div class="container clearfix" style="width:100%">
    <div class="main-wrap">
        <div class="search-wrap">
        </div>
        <div class="result-wrap" >
            <div class="result-title">
            </div>
            <div class="result-content" id="app" >
                <table class="result-tab" width="100%" id="addto">
                    <tr>
                        <th>消息ID</th>
                        <th>消息标题</th>
                        <th>发布时间</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${data}" var="v">
                        <tr >
                            <td>${v.systemNoticeId}</td>
                            <td>${v.systemNoticeTitle }</td>
                            <td><fmt:formatDate value="${v.systemNoticeDate }" pattern="yyyy-MM-dd/HH:mm:ss"/></td>
                            <td>
                                <button type="button" class="btn btn-success" onclick="updateget(${v.systemNoticeId})" data-toggle="modal" data-target="#myModal">修改</button>
                            </td>
                        </tr>
                    </c:forEach>
                </table>

            </div>
        </div>
    </div>
</div>

<div  class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" >
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    发布通知
                </h4>
            </div>
            <div >
                <form>
                    <table  class="addtab" id="cont">
                        <tr><th><i class="require-red">*</i>消息标题：</th><td><input  name='systemNoticeTitle' type="text"  placeholder="消息标题"></td></tr>
                        <tr><th><i class="require-red">*</i>消息内容：</th></br><td><textarea name="systemNoticeContent" placeholder="请输入消息内容！" rows="5" cols="43"></textarea></td></tr>
                    </table>
                </form>
            </div>
            <div class="modal-footer" id="foot" style="border-top:none;">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <button type="button" class="btn btn-primary" onclick="add()">
                    提交
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
<script>
    $(function () { $('#myModal').modal('hide')});
</script>
<script>
    $(function () { $('#myModal').on('hide.bs.modal', function () { })
    });
</script>
<script type="text/javascript">


    function updateget(systemNoticeId)
    {
        $.get("${pageContext.request.contextPath}/systemnotice/updatenotice.action",{systemNoticeId:systemNoticeId},function(returndata){
            if(returndata.code==1)
            {
                var systemNoticeTitle=returndata.data.systemNotice.systemNoticeTitle;
                var systemNoticeContent=returndata.data.systemNotice.systemNoticeContent;
                var str="<tr><th><i class='require-red'>*</i>消息标题：</th><td>"+systemNoticeTitle+"</td></tr>";
                str+="<tr><th><i class='require-red'>*</i>消息内容：</th></br><td><textarea name='systemNoticeContent2' placeholder='请输入消息内容！' rows='5' cols='43'>"+systemNoticeContent+"</textarea></td></tr>";
                str+="<input name='systemNoticeId2' type='hidden' value='"+systemNoticeId+"'/>";
                $("#cont").html(str);
                var str2="<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>";
                str2+="<button type='button' class='btn btn-primary' onclick='upd()'>提交</button>";
                $("#foot").html(str2);
            }
        });
    }

    function upd()
    {
        var systemNoticeContent=$("textarea[name=systemNoticeContent2]");
        var systemNoticeId=$("input[name=systemNoticeId2]");
        if(systemNoticeContent.val()=="")
        {
            layer.msg('消息内容不能为空', { offset: ['0px', '40%'], icon:7,time:2000});
            systemNoticeContent.focus();
            return ;
        }
        $.post("${pageContext.request.contextPath}/fixsystemnotice/updfun.action",{systemNoticeContent:systemNoticeContent.val(),systemNoticeId:systemNoticeId.val()},function(returndata){
            if(returndata.code==1){
                $(function () { $('#myModal').modal('hide')});
                layer.msg(returndata.message, { offset: ['0px', '40%'], icon:6,time:1000},function(){
                    location.reload();
                });
            }
            else
                layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:1000});

        });
    }


</script>
</html>